/*
*
* This file is part of Luces de 1984 (L1).
* Copyright (C) <2017>  <alkeon> [alkeon@autistici.org]
   
* L1 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L1 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l1.  If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <iostream>
#include "personajes.h"
#include <string>
#include <random>
#include "ncurses.h"
using namespace std;

//Constructor y destructor
Personaje::Personaje(int primer_argumento,int segundo_argumento,int tercer_argumento,int cuarto_argumento,int quinto_argumento){
	balas=primer_argumento;
	balas_dano=segundo_argumento;
	botiquin=tercer_argumento;
	ganzua=cuarto_argumento;
	isBot=quinto_argumento;
}
Personaje::~Personaje(){}

void Personaje::acierto(Personaje& agredido, Personaje& v){
	//dqmutil::setColor(1);
	cout<<"Narrador:Le diste"<<endl;
	this->balas-=1;
	agredido.vida-=this->balas_dano;
}
void Personaje::fallo(Personaje& v){
	this->balas-=1;
}

void Personaje::disparas(Personaje& agredido, Personaje& v){
	int aleatorio;
	std::uniform_int_distribution<int> d(0, 1);
	std::random_device rd1;
	aleatorio=d(rd1);
	if(aleatorio==1){
		this->acierto(agredido,v);
	} else {
		this->fallo(v);
	}
}

void Personaje::pegar(Personaje& agredido){
	agredido.vida -= this->ataque;
}

void Personaje::curar(Personaje& v){
	if(botiquin>0){		
		this->botiquin-=1;
		this->vida+=100;
		cout << "Narrador:Tu vida ->"<<this->vida<<endl;
		cout << "Narrador:Tus botiquines->"<<this->botiquin<<endl;
	} else {
		cout<<"Narrador:No te puedes curar"<<endl;
	}
}

void Personaje::disparo_acertado(Personaje& agredido){
	agredido.vida-=this->balas_dano;
	if(this->isBot==0){
		this->balas-=1;
	}
}
